﻿using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using System.Xml.Linq;

namespace EasyXaf.LowCode.WorkflowEditors.Models.Activities;

[DomainComponent]
[XafDisplayName("调试(Debug)")]
[ImageName("WF_Debug")]
[ActivityGroup(ActivityGroupConsts.DebugGroupName)]
public class DebugActivity : Activity
{
    [XafDisplayName("等级")]
    public DebugLevel Level
    {
        get => GetPropertyValue<DebugLevel>();
        set => SetPropertyValue(value);
    }

    [XafDisplayName("消息")]
    public string Message
    {
        get => GetPropertyValue<string>();
        set => SetPropertyValue(value);
    }

    public override string ImageName => "WF_Debug";

    public override string Color => "#C0392B";

    public override bool HasDetailView => true;

    public DebugActivity(IWorkflow workflow, ISequence sequence)
        : base(workflow, sequence)
    {
        Caption = "调试";
    }

    public override void WriteStateToXml(XElement element)
    {
        base.WriteStateToXml(element);

        SetXmlValue(element, nameof(Level), Level);
        SetXmlValue(element, nameof(Message), Message);
    }

    public override void ReadStateFromXml(XElement element)
    {
        base.ReadStateFromXml(element);

        Level = GetXmlValue<DebugLevel>(element, nameof(Level));
        Message = GetXmlValue<string>(element, nameof(Message));
    }
}
